<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<link href="css2/index.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="scripts/jquery-1.4.2.js"></script>


    <script type="text/javascript">
    
    jQuery(function(){
		if('<%= session.getAttribute("userId") %>'=='null'){
			
		}else{
			jQuery('#loginForm').hide();
	        jQuery('#loginSuccessForm').show();
		}
	});
    
	function login(){
		$.ajax({
	            //提交数据的类型 POST GET
	            type:"POST",
	            //提交的网址
	            url:"login.do",
	            dataType:"text",
	            //提交的数据
	            data:{
	            	username:jQuery('#txtUser').val(),
	            	password:jQuery('#txtPassword').val()
	            },
	            //返回数据的格式
	            datatype: "html",//"xml", "html", "script", "json", "jsonp", "text".
	            //在请求之前调用的函数
	            //beforeSend:function(){$("#msg").html("logining");},
	            //成功返回之后调用的函数            
	            success:function(data){
	           		//window.location.href = "www.baidu.com"; 
	           		//alert("success"==data.trim());
	           		if(data.trim()!="用户名或密码错误"){
	           		
	           			jQuery('#loginForm').hide();
	           			jQuery('#loginSuccessForm').show();
	           			
	           		}else{
	           			alert(data);
	           		}
	            },
	            //调用执行后调用的函数
	            //调用出错执行的函数
	            error: function(){
	               alert("服务器出现问题，请联系客服或稍后重试。");
	            }       
	         });
	   
  
	}
	
	function logout(){
		jQuery('#loginForm').show();
	    jQuery('#loginSuccessForm').hide();
	    jQuery('#txtUser').val("");
	    jQuery('#txtPassword').val("");
	    <% session.setAttribute("userId",null); %>
	}
</script>

</head>
<body>

 

			
				<div class="t_block flightse">
					<div class="hd">
						<ul id="changeType" class="wrap">
							<li   class="active">
								<span>登录</span>
							</li>
							<li>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
							</li>
							<li   class="active">
								<span><a href='signIn.jsp'>免费注册</a></span>
							</li>
						</ul>
					</div>
					<div class="ct" id="loginForm">
						<form>
							<table class="tbl">
								<tr>
									<td>帐&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</td>
									<td><input type="text" name="txtUser" id="txtUser" /></td>
								</tr>
								<tr>
									<td>密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码：</td>
									<td><input type="password" name="txtPassword" id="txtPassword" /></td>
								</tr>
								<tr>
									<td>&nbsp;</td>
									<td><input class="btn" value="登 录" type="button" onclick="javascript:login()" /></td>
								</tr>
							</table>
						</form>
					</div>
				
					<div class="ct" id="loginSuccessForm" style="display:none">
						
						<table class="tbl">
							<tr>
								<td>帐&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</td>
								<td>普通会员&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
							</tr>
							<tr>
								<td><a href="#" onclick="javascript:logout()">退出&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
								<td><input class="btn" value="进入我的账户" type="button" onclick="window.location.href='driveSelfOrder.jsp'" /></td>
							</tr>
						</table>
						
					</div>
					
				
				</div>
				
					
            
    
</body>
</html>